package day10.problem1;

import java.util.*;

//最长回文子串
//https://www.nowcoder.com/practice/b4525d1d84934cf280439aeecc36f4af?tpId=182&tqId=34752&ru=/exam/oj

public class Solution {

    public int getLongestPalindrome (String A) {
        int n = A.length();
        int ret = 0;
        for(int i = 0; i<n; i++) {
            int l = i, r = i;
            while(l >= 0 && r < n && A.charAt(l) == A.charAt(r)) {
                l--;
                r++;
            }
            l++;r--;
            ret = Math.max(ret, r-l+1);

            l = i;r = i+1;
            while(l >= 0 && r < n && A.charAt(l) == A.charAt(r)) {
                l--;
                r++;
            }
            l++;r--;
            ret = Math.max(ret, r-l+1);
        }
        return ret;
    }
}